pkgbase=libssh
pkgname=('libssh' 'libssh-devel')
pkgver=0.9.5
pkgrel=1
pkgdesc='Library for accessing ssh client services through C libraries'
url='https://www.libssh.org/'
license=('LGPL')
arch=('i686' 'x86_64')
depends=('zlib' 'libopenssl')
makedepends=('cmake' 'python' 'openssl-devel')
source=("https://www.libssh.org/files/${pkgver%.*}/$pkgname-$pkgver.tar.xz"{,.asc}
        0001-Work-around-internal-compiler-error.patch)
sha256sums=('acffef2da98e761fc1fd9c4fddde0f3af60ab44c4f5af05cd1b2d60a3fa08718'
            'SKIP'
            'f34ae4dcc7770b36bdc76f71096ccd95e86a800a7bbfb2e44f2217fe9fa3ea36')
validpgpkeys=('8DFF53E18F2ABC8D8F3C92237EE0FC4DCC014E3D') # Andreas Schneider <asn@cryptomilk.org>

prepare() {
  mkdir -p build

  cd $pkgname-$pkgver
  patch -p1 <$srcdir/0001-Work-around-internal-compiler-error.patch
}

build() {
  cd build
  cmake ../$pkgname-$pkgver \
    -DCMAKE_INSTALL_PREFIX=/usr \
    -DWITH_GSSAPI=OFF \
    -DUNIT_TESTING=OFF
  make
  make DESTDIR="$srcdir/dest" install
}

package_libssh() {
  mkdir -p $pkgdir/usr/bin
  cp -rf $srcdir/dest/usr/bin/* $pkgdir/usr/bin/
}

package_libssh-devel() {
  mkdir -p $pkgdir/usr/include
  cp -rf $srcdir/dest/usr/include/* $pkgdir/usr/include/

  mkdir -p $pkgdir/usr/lib
  cp -rf $srcdir/dest/usr/lib/* $pkgdir/usr/lib/
}
